package cn.fay.chapter17;

import java.util.ArrayList;
import java.util.HashSet;

import cn.fay.chapter15.Generator;
import cn.fay.chapter16.RandomGenerator;

public class CollectionData<T> extends ArrayList<T> {
	private static final long serialVersionUID = 1L;

	public CollectionData(Generator<T> gen,int quantity) {
		for (int i = 0; i < quantity; i++) {
			add(gen.next());
		}
	}
	public static <T> CollectionData<T> list(Generator<T> gen,int quantity) {
		return new CollectionData<T>(gen, quantity);
	}
	
	public static void main(String[] args) {
		System.out.println(new ArrayList<String>(CollectionData.list(
				new RandomGenerator.String(9), 7)));
		System.out.println(new HashSet<Integer>(new CollectionData<Integer>(
				new RandomGenerator.Integer(20), 20)));
	}
}
